/*
 *  $Id: Rectangle.cs 1205 2010-11-23 15:50:19Z thenn.erannor $
 *	This file is a part of Ragima CCG.
 *	(C) 2008-2010 Ragima development group.
 *
 *	Licensed under the terms of the GNU GPL License version 2.
 *
 */

using AgateLib.Geometry;

using Nereal.Serialization;
using Nereal.Serialization.TypeInfos;

namespace Ragima.Serialization {
    [TypeInfo(typeof(Rectangle))]
    public class RectangleTypeInfo : ValueTypeInfo<Rectangle> {
        public override bool Equals(Rectangle a, Rectangle b) {
            return a == b;
        }

        public override Rectangle ConvertFromString(string value) {
            var data = IntArrayConverter.GetArray(value, 4);
            return new Rectangle(data[0], data[1], data[2], data[3]);
        }

        public override string ConvertToString(Rectangle value) {
            return IntArrayConverter.GetString(value.X, value.Y, value.Width, value.Height);
        }
    }
}
